/**
 * Created by CHENED2 on 8/24/2015.
 */



//console.log('A');
//setTimeout(function (){
//    console.log('B');
//}, 100);
//setTimeout(function(){
//    while (true) {console.log('C')}
//}, 1000);
//setTimeout(function (){
//    console.log('D');
//}, 2000);

// print D C A A A..........


function print()
{
    console.log('1' );
    setTimeout(function(){
        console.log( '2' );
    } , 5);
}
for (var i = 0; i < 1000000; i++) {
    print();
}

//print 1 1 1 1 1 1 ... 2 2 2 ...2



//onload()?onclick()?onmouseover()?setTimeOut()?setInterval()?ajax